package Datastructures.Queue;

import java.util.Scanner;

public class queueDemo {
    public static void main(String[] args)  {
        System.out.println("测试======");
        ArrayQueue queue=new ArrayQueue(4);
        int key;//接受用户输入
        Scanner sc=new Scanner(System.in);
        boolean loop=true;
        while(loop){
            System.out.println("1显示队列");
            System.out.println("2添加数据");
            System.out.println("3取出数据");
            System.out.println("4取出队头");
            System.out.println("5退出程序");
      key=sc.nextInt();
            switch (key){
                case'1':
                    queue.showQueue();
                    break;
                case'2':
                    System.out.println("输入一个数");
                    int value=sc.nextInt();
                    queue.addQueeu(value);
                    break;
                case'3':
                   try{
                       int res=queue.getQueue();
                        System.out.printf("取出的数为%d\n",res);
                   }catch (Exception e){
                       System.out.println(e.getMessage());
                   }
                    break;
                case'4':
                    try{
                        int res=queue.headQueue();
                        System.out.printf("取出的队头数为%d\n",res);
                    }catch (Exception e){
                        System.out.println(e.getMessage());
                    }
                    break;

                case'5':
                   sc.close();
                   loop=false;
                    break;
                default:
                    break;
            }
        }
System.out.println("exit");
    }

}
